﻿
using Xacml.Core;
using System;
using System.Xml;

namespace Xacml.Core.Policy
{
  public class RuleElement : RuleElementReadWrite
  {
    public override string Id
    {
      set
      {
        throw new NotSupportedException();
      }
    }

    public override string Description
    {
      set
      {
        throw new NotSupportedException();
      }
    }

    public override ConditionElementReadWrite Condition
    {
      get
      {
        if (base.Condition != null)
          return (ConditionElementReadWrite) new ConditionElement(base.Condition.FunctionId, base.Condition.Arguments, this.SchemaVersion);
        return (ConditionElementReadWrite) null;
      }
      set
      {
        throw new NotSupportedException();
      }
    }

    public override TargetElementReadWrite Target
    {
      get
      {
        if (base.Target != null)
          return (TargetElementReadWrite) new TargetElement(base.Target.Resources, base.Target.Subjects, base.Target.Actions, base.Target.Environments, base.Target.SchemaVersion);
        return (TargetElementReadWrite) null;
      }
    }

    public override Effect Effect
    {
      set
      {
        throw new NotSupportedException();
      }
    }

    public RuleElement(string id, string description, TargetElementReadWrite target, ConditionElementReadWrite condition, Effect effect, XacmlVersion schemaVersion)
      : base(id, description, target, condition, effect, schemaVersion)
    {
    }

    public RuleElement(XmlReader reader, XacmlVersion schemaVersion)
      : base(reader, schemaVersion)
    {
    }
  }
}
